import DataGrid from './packages/datagrid'
import Form from './packages/form';
import Empty from './packages/empty';
import Group from './packages/group';
import Img from './packages/img';
import Select from './packages/select';
import Carousel from './packages/carousel';
import Date from './packages/date';
import { deepClone, validData, findArray, setPx, sortArrys, isJson } from './utils/util';
import { validatenull, asyncValidator } from './utils/validate.js';

const components = [
	Empty,
	Group,
	Img,
	Select,
	Carousel,
	Date,
	Form,
	DataGrid
]
function install(Vue, opts = {}) {
    //if (axios || window.axios) Vue.prototype.$http = axios || window.axios;
    //初始化指令
    //directive(Vue);
	Vue.prototype.deepClone = deepClone;
	Vue.prototype.isJson = isJson;
	Vue.prototype.setPx = setPx;
	Vue.prototype.validData = validData;
	Vue.prototype.sortArrys = sortArrys;
	Vue.prototype.findArray = findArray;
	Vue.prototype.validatenull = validatenull;
	Vue.prototype.asyncValidator = asyncValidator;
    components.map(component => {
        Vue.component(component.name, component);
		if (component.alias){
			component.alias.forEach(alias=>{
				Vue.component(alias, component);
			})
		}
    });
}
// if (window.Vue) {
//     install(window.Vue, window.axios);
// }


export default {
  install,
  DataGrid,
  Empty,
  Group,
  Select,
  Carousel,
  Date,
  Form,
  Img
}
